//
//  COKVATrackerEvent.m
//  CocoProject
//
//  Created by Vill on 2023/11/3.
//

#import "COKVATrackerEvent.h"
@import KochavaTracker;
@import FBSDKCoreKit;

@implementation COKVATrackerEvent

+ (instancetype)shared{
    static COKVATrackerEvent *manager;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[COKVATrackerEvent alloc] init];
    });
    return manager;
}

/**
 *  注册埋点
 */
- (void)loginRegisterEvent{
    [KVAEvent sendCustomWithEventName:@"ko_sign_up" infoString:@"ko-h1EventTap_Sign_up"];
    [[FBSDKAppEvents shared] logEvent:FBSDKAppEventNameCompletedRegistration];
}

/**
 *  购买点击
 *  money  金额
 */
- (void)clickBuyCoinsEvent:(NSString *)money{
    [[FBSDKAppEvents shared] logPurchase:[money doubleValue] currency:@"USD"];
    if ([money isEqualToString:@"0.99"]){
        [KVAEvent sendCustomWithEventName:@"ko_0.99" infoString:@"ko-h1EventTap_0.99"];
    }else if ([money isEqualToString:@"19.99"]){
        [KVAEvent sendCustomWithEventName:@"ko_19.99" infoString:@"ko-h1EventTap_19.99"];
    }else if ([money isEqualToString:@"4.99"]){
        [KVAEvent sendCustomWithEventName:@"ko_4.99" infoString:@"ko-h1EventTap_4.99"];
    }else if ([money isEqualToString:@"9.99"]){
        [KVAEvent sendCustomWithEventName:@"ko_9.99" infoString:@"ko-h1EventTap_9.99"];
    }else if ([money isEqualToString:@"24.99"]){
        [KVAEvent sendCustomWithEventName:@"ko_49.99" infoString:@"ko-h1EventTap_24.99"];
    }else if ([money isEqualToString:@"49.99"]){
        [KVAEvent sendCustomWithEventName:@"ko_49.99" infoString:@"ko-h1EventTap_49.99"];
    }else if ([money isEqualToString:@"99.99"]){
        [KVAEvent sendCustomWithEventName:@"ko_99.99" infoString:@"ko-h1EventTap_99.99"];
    }
    [KVAEvent sendCustomWithEventName:@"Purchase" infoDictionary:@{
      @"price": @([money doubleValue]),
      @"name": @"Loot Box"
    }];
}


@end
